<template>
  <div v-loading="loading">
    <div class="inputStr">
      <el-input v-model="pagination.queryContent" clearable style="width: 150px" placeholder="请输入考生姓名"></el-input>
      <el-button type="primary" icon="el-icon-search" style="margin: 10px" v-model="pagination.queryContent"
                 @click="findPage(paperId)">搜索
      </el-button>

      <el-button type="info" plain style="margin-left: 50px" @click="goAllPaper">返回</el-button>
    </div>
    <el-table
        v-loading="loading"
        :data="userAnswerList"
        style="width: 100%">
      <el-table-column
          label="姓名"
          align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.user.realName }}</span>
        </template>
      </el-table-column>
      <el-table-column
          align="center"
          label="主观题得分">
        <template slot-scope="scope">
          <el-tag  effect="dark" v-html="scope.row.subjectiveScore">
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
          align="center"
          label="客观题得分">
        <template slot-scope="scope">
          <el-tag   effect="dark"
                  v-html="scope.row.isMarkSub == 3 ? '未评分' : scope.row.objectiveScore">标签四
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column
          align="center"
          prop="totalScore"
          label="总分">
      </el-table-column>
<!--      <el-table-column-->
<!--          align="center"-->
<!--          label="试卷类型">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ scope.row.paperType == 1 ? '随机卷' : '手动卷' }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
          align="center"
          prop="createTime"
          label="交卷时间">
      </el-table-column>
      <el-table-column
          fixed="right"
          align="center"
          label="操作">
        <template slot-scope="scope">
          <el-button @click="goPaperDetail(scope.row.user.id,scope.row.user.realName,paperName)"
                     :type="scope.row.isMarkSub != 3?'primary':'warning'">
            {{ scope.row.isMarkSub != 3 ? '试卷查看' : '试卷评分' }}
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div style="padding-top: 40px">
      <el-pagination
          class="pagiantion"
          :total="total"
          @current-change="handleSelectionChange"
          :current-page="pagination.currentPage"
          :page-size="pagination.pageSize"
          layout="total, prev, pager, next, jumper">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "AnswerUserList",
  data() {
    return {
      loading: false,
      paperId: null,
      paperName: null,
      total: 0,
      userAnswerList: [],
      pagination: {
        currentPage: 1,
        pageSize: 5,
        queryContent: "",
        categoryId: null
      },
    }
  },
  methods: {
    goPaperDetail(userId, realName, paperName) {
      this.$router.replace('/paper/detail?paperId=' + this.paperId + "&userId=" + userId + "&realName=" + realName + "&paperName=" + paperName);
    },
    goAllPaper() {
      this.$router.replace('/question/AllPaper');
    },
    findPage(paperId) {
      this.loading = true;
      this.axios.post("/answer/findPage/" + paperId, this.pagination).then(resp => {
        if (resp.data.statusCode == 200) {
          this.total = resp.data.data.total;
          //this.userId=sessionStorage.getItem("userId");
          //alert(this.userId)
          this.userAnswerList = resp.data.data.data;
        }
        this.loading = false;
      })
    },
    handleSelectionChange(currentPage) {
      this.pagination.currentPage = currentPage;
      this.findPage();
    },
  },
  mounted() {
    let paperId = this.$route.query.paperId;
    let paperName = this.$route.query.paperName;
    this.paperId = paperId;
    this.paperName = paperName;
    this.findPage(paperId);

  }
}
</script>

<style scoped>
.inputStr {
  width: 550px;
  margin-left: 500px;
}
</style>
